/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 涛
 * Date: 2023-09-21
 * Time: 17:56
 */

import java.util.Scanner;

/**
 * 实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码.
 * 如果用户名密码出错, 使用自定义异常的方式来处理
 */

class UserNameException extends Exception {
    public  UserNameException(String message) {
        super(message);
    }
}

class PasswordException extends Exception {
    public PasswordException(String message) {
        super(message);
    }
}

class Login {
     static String userName1 = "admin";
     static String password1 = "12345";

    public static void loginInfo(String userName, String password) throws UserNameException, PasswordException{
        if(!userName1.equals(userName)) {
            throw new UserNameException("用户名错误");
        }
        if(!password1.equals(password)) {
            throw new PasswordException("密码错误");
        }
        System.out.println("登陆成功");
    }

}
public class UserLogin {

    public static void main(String[] args) {
        try {
            Login.loginInfo("admin1", "123451");
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}

